ABOUT DIALOG EDITOR

Dialog Editor is QM extension that you can use to create and edit dialogs. Created dialog definition later is used by function ShowDialog.

HOW TO CREATE DIALOG

Select "New Dialog" in QM "File\New" menu and click "Run" button. Will run Dialog Editor. Add controls, order them, change text, etc, and click "Apply". It will insert dialog definition in QM editor text. To edit dialog later, run Dialog_Editor (it runs when you press "Run" button when first line of QM editor text is " /Dialog_Editor"). If it finds dialog definition in QM editor text, it loads that definition.

DIALOG EDITOR TIPS

Select control: click it. Small red rectangle will appear at top-left corner.
Delete selected control: click "x" button.
Move control:  drag with left button.
Resize control:  drag with right button.
Bring control to top of Z order and tab order:  Shift+click or Shift+drag.
Bring control to bottom:  Ctrl+click or Ctrl+drag.
Resize form:  resize dialog editor.
Underline character in text of control:  place ampersand (&) before.
Z-order/tab-order controls: hold down Shift and click all controls starting from control which must be at bottom of Z order. You can skip static controls and group buttons (frames).
Create group of option buttons: add "Option first", several "Option next", and Shift+click all them, starting from last and ending with first ("Option first").

DIALOG DEFINITION FORMAT (can skip it)

Dialog definition begins with "BEGIN DIALOG and ends with "END DIALOG". First line defines dialog window, other lines defines controls. Line format: id class style exstyle x y cx cy text
Order of control definitions is same as Z order in dialog (topmost control is at first line after form definition, etc).
Dialog definition can be commented (green).

HOW TO RUN DIALOG

To show dialog, call function ShowDialog from some function or macro. First argument must be name (in quotes) of item, in which is dialog definition. Other arguments are optional. Second argument can be 0 or address of custom dialog procedure. Third argument can be 0 or adress of array of strings, as explained in next topic.

HOW TO GET DIALOG CONTROLS DATA

When you save (Apply) dialog definition, dialog usage sample is copied to Clipboard. Example:

str controls = "3 5"
str Edit3 Button5
if(!ShowDialog("Dialog2" 0 &controls)) ret

First str variable contains identifiers of desired controls, separated with spaces. Then follows str variables for each control, which id is included in first variable (in same order). Third argument of ShowDialog must be address of first variable.

After you close dialog, variables contain data from corresponding controls in dialog. Format:
1. Check and Option buttons: "1" if checked and "0" if not checked.
2. ListBox (except multiplesel) and ComboBox: "index string". Here index is zero-based index of selected item, string is text of selected item. If not selected any item, then index is -1. Use function val to get index as numeric value.
3. ListBox multiplesel: string, consisting of '0' and '1' characters. For example, if selected items 1 and 3 in 4-item listbox, then string will be "0101".
4. Other controls: text of control.

Dialog can be modal (ShowDialog returns when dialog is closed; it is default style) or modeless (ShowDialog creates dialog and returns immediately). Usually are used modal dialogs. You cannot simply get data from modeless dialog. To make modeless dialog useful, you must create dialog procedure for it. ShowDialog for modeless dialog returns dialog window handle.

ShowDialog for modal dialog returns 1 on OK, 0 on Cancel. When you click other push-button in dialog that does not have custom dialog procedure, it closes dialog, and ShowDialog returns button id. If error occurs and dialog cannot be shown, then ends macro.

HOW TO SET DIALOG CONTROLS DATA

If you want to initialize some controls before showing dialog, set corresponding strings as follows:
1. Check and Option buttons: if string is "1", button will be checked.
2. ListBox and ComboBox: string should contain text of every item, each in separate line. Item, preceded with ampersand (&) will be selected.
3. Static icon: file (can be any file or folder). If first character is ampersand (&), then will be used large icon, else - small.
4. Static bitmap: bmp file.
5. Dialog itself (id=0): title bar text.
6. Other controls: text of control.
Example:

str controls = "3 5 6 7 4"
str Button3 = 1
str ComboBox5 = "Sunday[]&Monday[]Tuesday"
str Edit6 = "Default text"
str Static7 = "&files.ico"
str Static4 = "c:\pictures\tree.bmp"
if(!ShowDialog("Dialog2" 0 &controls)) ret
